package com.netease.nim.uikit.team.helper;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.netease.nim.uikit.cache.TeamDataCache;
import com.netease.nimlib.sdk.team.model.Team;

/**
 * Created by nicl on 2017/9/27.
 * 读取群扩展信息
 */

public class TeamExtendHelper {

    public static int getFamilyLv(String teamId){
        Team team = TeamDataCache.getInstance().getTeamById(teamId);
        if (team!=null){
            try {
                String extend = team.getExtServer();
                JSONObject object = JSON.parseObject(extend);
                return object.getIntValue("lv");
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return -1;

    }
    public static boolean isFamilyLocked(String teamId){
        Team team = TeamDataCache.getInstance().getTeamById(teamId);
        if (team!=null){
            try {
                String extend = team.getExtServer();
                JSONObject object = JSON.parseObject(extend);
                return object.getIntValue("beLocked")==1;
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return false;

    }

}
